home *** CD-ROM | disk | FTP | other *** search
- Frequently Asked Questions (FAQS);faqs.379
-
-
-
- Answer: You can't. Text stores an ordinary string, and points where
- `highlights' of various types begin and end. These highlights are all the
- control you have over components of the text. See the previous question.
-
-
- -----------------------------------------------------------------------------
- Subject: 40) How can I change the font of text in the Text widget? I want
- some of the text in one font, some in another.
-
- Answer: You can't in Text (see the previous question). If you wanted readonly
- text, you could do it by using a label instead. Label uses XmStrings, which
- can contain multiple character sets in the one string.
-
- -----------------------------------------------------------------------------
- Subject: 41) Is there an emacs binding for the text widget?
-
- Answer: This set is due to Kee Hinckley (nazgul@alfalfa.com):
-
- *XmText.translations: #override\n\
- Ctrl <Key>b: backward-character()\n\
- Alt <Key>b: backward-word()\n\
- Meta <Key>b: backward-word()\n\
- Shift Alt <Key>b: backward-word(extend)\n\
- Shift Meta <Key>b: backward-word(extend)\n\
- Alt <Key>[: backward-paragraph()\n\
- Meta <Key>[: backward-paragraph()\n\
- Shift Alt <Key>[: backward-paragraph(extend)\n\
- Shift Meta <Key>[: backward-paragraph(extend)\n\
- Alt <Key><: beginning-of-file()\n\
- Meta <Key><: beginning-of-file()\n\
- Ctrl <Key>a: beginning-of-line()\n\
- Shift Ctrl <Key>a: beginning-of-line(extend)\n\
- Ctrl <Key>osfInsert: copy-clipboard()\n\
- Shift <Key>osfDelete: cut-clipboard()\n\
- Shift <Key>osfInsert: paste-clipboard()\n\
- Alt <Key>>: end-of-file()\n\
- Meta <Key>>: end-of-file()\n\
- Ctrl <Key>e: end-of-line()\n\
- Shift Ctrl <Key>e: end-of-line(extend)\n\
- Ctrl <Key>f: forward-character()\n\
- Alt <Key>]: forward-paragraph()\n\
- Meta <Key>]: forward-paragraph()\n\
- Shift Alt <Key>]: forward-paragraph(extend)\n\
- Shift Meta <Key>]: forward-paragraph(extend)\n\
- Ctrl Alt <Key>f: forward-word()\n\
- Ctrl Meta <Key>f: forward-word()\n\
- Ctrl <Key>d: kill-next-character()\n\
- Alt <Key>BackSpace: kill-previous-word()\n\
- Meta <Key>BackSpace: kill-previous-word()\n\
- Ctrl <Key>w: key-select() kill-selection()\n\
- Ctrl <Key>y: unkill()\n\
- Ctrl <Key>k: kill-to-end-of-line()\n\
- Alt <Key>Delete: kill-to-start-of-line()\n\
- Meta <Key>Delete: kill-to-start-of-line()\n\
- Ctrl <Key>o: newline-and-backup()\n\
- Ctrl <Key>j: newline-and-indent()\n\
- Ctrl <Key>n: next-line()\n\
- Ctrl <Key>osfLeft: page-left()\n\
- Ctrl <Key>osfRight: page-right()\n\
- Ctrl <Key>p: previous-line()\n\
- Ctrl <Key>g: process-cancel()\n\
- Ctrl <Key>l: redraw-display()\n\
- Ctrl <Key>osfDown: next-page()\n\
- Ctrl <Key>osfUp: previous-page()\n\
- Ctrl <Key>space: set-anchor()\n
-
-
- ! If you'd like the Delete key to work like backspace instead of deleting
- ! backwards, add the following definition to the lines above.
- ! <Key>osfDelete: delete-previous-character()\n\
-
- ! These aren't included because they could intefere with
- | menu accelerators (or vice versa)
- ! Alt <Key>p: backward-paragraph()\n\
- ! Meta <Key>p: backward-paragraph()\n\
- ! Shift Alt<Key>p: backward-paragraph(extend)\n\
- ! Shift Meta<Key>p: backward-paragraph(extend)\n\
- ! Alt <Key>w: copy-clipboard()\n\
- ! Meta <Key>w: copy-clipboard()\n\
- ! Ctrl Alt <Key>w: cut-clipboard()\n\
- ! Ctrl Meta <Key>w: cut-clipboard()\n\
- ! Alt <Key>y: paste-clipboard()\n\
- ! Meta <Key>y: paste-clipboard()\n\
- ! Alt <Key>f: forward-word()\n\
- ! Meta <Key>f: forward-word()\n\
- ! Alt <Key>n: forward-paragraph()\n\
- ! Meta <Key>n: forward-paragraph()\n\
- ! Shift Alt <Key>n: forward-paragraph(extend)\n\
- ! Shift Meta <Key>n: forward-paragraph(extend)\n\
- ! Shift Alt <Key>f: forward-word(extend)\n\
- ! Shift Meta <Key>f: forward-word(extend)\n\
- ! Alt <Key>d: kill-next-word()\n\
- ! Meta <Key>d: kill-next-word()\n\
- ! Alt <Key>h: select-all()\n\
- ! Meta <Key>h: select-all()\n\
-
- Similar sets of translations have been suggested by others.
-
- -----------------------------------------------------------------------------
- Subject: 42) How can I use a file as the text source for a Text widget?
-
- Answer: You can't do it directly like you can with the Athena Text widget.
- Instead, read the text from the file into a string (all of it!) and then use
- XmTextSetString. Alternatively, read blocks of characters and add them at the
- end of the text using XmTextInsertString. The following is an excerpt from
- Dan Heller's "file_browser.c":
-
- /* file_browser.c -- use a ScrolledText object to view the
- * contents of arbitrary files chosen by the user from a
- * FileSelectionDialog or from a single-line text widget.
- */
-
- ...
- struct stat statb;
-
- /* make sure the file is a regular text file and open it */
- if (stat(filename, &statb) == -1 ||
- (statb.st_mode & S_IFMT) != S_IFREG ||
- !(fp = fopen(filename, "r"))) {
- if ((statb.st_mode & S_IFMT) == S_IFREG)
- perror(filename); /* send to stderr why we can't read it */
- else
- fprintf(stderr, "%s: not a regular file0, filename);
- XtFree(filename);
- return;
- }
-
- /* put the contents of the file in the Text widget by allocating
- * enough space for the entire file, reading the file into the
- * allocated space, and using XmTextFieldSetString() to show the file.
- */
- if (!(text = XtMalloc((unsigned)(statb.st_size+1)))) {
- fprintf(stderr, "Can't alloc enough space for %s", filename);
- XtFree(filename);
- fclose(fp);
- return;
- }
-
- if (!fread(text, sizeof(char), statb.st_size+1, fp))
- fprintf(stderr, "Warning: may not have read entire file!0);
-
- text[statb.st_size] = 0; /* be sure to NULL-terminate */
-
- /* insert file contents in Text widget */
- XmTextSetString(text_w, text);
-
-
-
-
- -----------------------------------------------------------------------------
- Subject: 43) How can put Text in overstrike mode instead of insert?
-
- Answer: There is no direct way. This was posted by Edmond Pitt
- (ejp@bohra.cpg.oz) The correct answer to the question is to put the following
- in a modifyVerify callback, where 'mvcb' is the XmTextVerifyCallbackStruct,
- and 'overstriking' is defined by you:
-
- if (overstriking && mvcb->text->length == 1)
- {
- _XmTextDisableRedisplay(w,FALSE);
- XtCallActionProc(w,"delete-next-character",mvcb->event,0);
- _XmTextEnableRedisplay(w);
- }
-
- _XmText{Dis,En}ableRedisplay() are XmText{Dis,En}ableRedisplay() in 1.0, but
- X11R3 has no XtCallActionProc() anyway. For this environment you need my 1.0.3
- Text widget patches posted last year & available on request.
-
-
- -----------------------------------------------------------------------------
- Subject: 44) How can I make the Delete key do a backspace?
-
- Answer: Put this in your .Xdefaults
-
- *XmText.translations: #override <Key>osfDelete: delete-previous-character()
-
-
- -----------------------------------------------------------------------------
- Subject: 45) TOPIC: LIST WIDGET
-
- -----------------------------------------------------------------------------
- Subject: 46) How do I best put a new set of items into a list?
-
- Answer: Set the new list count and list by XtSetArgs and install them by
- XtSetValues.
-
- XmString list[SIZE];
- int list_size;
-
- XtSetArg (args[n], XmNitemCount, list_size); n++;
- XtSetArg (args[n], XmNitems, list); n++;
- XtSetValues (w, args, n);
-
- Each time the list is reset by this the old contents are freed by the widget
- and the new supplied list is copied. Do *not* free the old list of items
- yourself as this would result in the space being freed twice. It is not
- necessary to remove the items one at a time, nor to "zero" out the list first.
-
- -----------------------------------------------------------------------------
- Subject: 47) Can I have strings with different fonts in a list?
-
- Answer: Yes. The strings are XmStrings. Each one can be created using a
- different character set using a different font.
-
-
- -----------------------------------------------------------------------------
- Subject: 48) Can I get a bitmap to show in a list item like I can in a Label?
- I want to place a bitmap along with some normal text in my list items.
-
- Answer: No. The list contains XmStrings, and these only allow text in various
- character sets. The workaround is to define your font containing the icons you
- want. Then you can create a fontlist containing your icon font and the font
- you want the text in, and then make your items multi-segment XmStrings where
- the first segment contains the code of the icon you want with a charset that
- matches the icon font in your fontlist and the second segment with a charset
- matching the text font.
-
-
- -----------------------------------------------------------------------------
- Subject: 49) Can I have items with different colours in a list?
-
- Answer: No. The list contains XmStrings, and these only allow text in various
- character sets. Since the items are XmStrings, you can already change the font
- of an item by replacing it with an item with the same text and a different
- charset tag. Adding support for color would require modification of the
- internal data structure in XmList as well as modification to the drawing
- routines. A possible workaround is to use a rowcolumn of buttons which can be
- individually set. However, you would have to do all list functionality
- yourself.
-
-
- -----------------------------------------------------------------------------
- Subject: 50) Can I grey out an item in a list? I want to make insensitive
- items in a list so that they cannot be selected.
-
- Answer:
-
- From W. Scott Meeks of OSF:
-
- Unfortunately, you can't do it directly since the list items aren't individual
- widgets. We've had other requests for this technology, but it didn't make the
- cut for 1.2; it should be in some future release.
-
- However, you can probably fake it in your application with some difficulty.
- First, a list item is an XmString, so you can specify a different charset for
- the item than for other items in the list and then specify a font in the
- list's fontlist that matches the charset and gives you the visual you want.
- The next problem is making the item unselectable. One idea would be to have
- the application keep track of the insensitive items and the items currently
- selected. Then you would set up a selection callback that when called would
- check the item selected against the list of insensitive items and if the
- selected item matched would deselect that item and reselect the previously
- selected items. Otherwise it would just update the application's list of
- selected items. The major drawback with this approach is that you'll get
- flashing whenever the list selects an item and your application immediately
- de-selects. Unfortunately I can't think of a way around this without mucking
- with the list internals.
-
- Another alternative suggested is to use instead a column of say read only text
- widgets which you can make insensitive.
-
- -----------------------------------------------------------------------------
- Subject: 51) Can I have multi-line items in a list?
- [Last modified: August 92]
-
- Answer: Motif 1.0 and 1.1 both have problems with multi-line items in a list.
- They should work okay in Motif 1.2.
-
- -----------------------------------------------------------------------------
- Subject: 52)+How can I tell the position of selected items in a list?
-
- [Last modified: Oct 92]
-
- Answer: From W. Scott Meeks:
-
- 1) All XmList selection callbacks get an XmListCallbackStruct which includes
- the item selected and its position. In addition, the multiple and extended
- selection callbacks also get a list of the selected items. This approach
- requires that your application saves this information if you need it outside
- of the immediate callback.
-
- 2) At any time you can XtGetValues the XmNselectedItems and
- XmNselectedItemCount resources. The problem with this approach is that
- identical items may or may not show up in multiple times in this list and the
- position in the selectedItems list may not relate directly to the position in
- the items list.
-
- 3) You can call XmListGetSelectedPos on the list widget. This will return a
- list of the positions of all selected items.
-
- -----------------------------------------------------------------------------
- Subject: 53) TOPIC: FILE SELECTION BOX WIDGET
-
- -----------------------------------------------------------------------------
- Subject: 54) What is libPW.a and do I need it? My manual says I need to link
- in libPW.a to use the File Selection Box. I can't find it on my system.
-
- Answer: The libPW.a is the Programmers Workbench library which is an ATT
- product not included in Berkeley based systems, hence it is not found in SunOS
- or Ultrix, but is found on HP-UX (a Berkeley/ATT hybrid which chose ATT in
- this case). It contains the regex(3) routines (regcmp, regex). Some systems
- which don't have these in the libc.a need to link with -lPW. Some systems
- which have the regex(3) routines in there also have the libPW.a. If you have
- regex(3) in libc, and it works, don't link with libPW. If you don't have
- regex(3) in libc, and you don't have a libPW, then check some sites on the net
- for public domain replacements (several exist), or call your vendor.
-
- In most versions of Motif (see the doco), you can compile FileSB.c with
- -DNO_REGEX if you don't have it.
-
- -----------------------------------------------------------------------------
- Subject: 55) What are these compile errors: Undefined symbol _regcmp?
-
- Answer: You need to link in the libPW library - see previous question.
-
-
- -----------------------------------------------------------------------------
- Subject: 56) What's wrong with the Motif 1.0 File Selection Box? I can't set
- the directory, change the directory or get the file mask to work.
-
- Answer: The 1.0 File Selection Box is broken, and these don't work. They
- weren't fixed until Motif 1.04. Use these later versions of 1.0 or switch to
- Motif 1.1 where it changed a lot.
-
- Joe Hildebrand has a work-around for some of this: Before popping up an
- XmFileSelectionDialog, change to the directory you want. When a file is
- selected, check if it is a directory, so that we can change to it. i.e.
-
- static void show_file_box_CB(w, client_data, call_data)
- Widget w;
- Widget client_data;
- XmAnyCallbackStruct *call_data;
- {
- chdir("/users/hildjj/files");
- XtManageChild(client_data);
- }
-
- static void val_save(w, client_data, call_data)
- Widget w;
- Widget client_data;
- XmSelectionBoxCallbackStruct *call_data;
- {
- struct stat buf; /* struct stat is defined in stat.h */
- char *filename;
-
- /* get the file name from the FileSelectionBox */
- filename = SmX(call_data->value);
-
- /* get the status of the file named filename, and put it into buf */
- if (!stat(filename, &buf))
- {
- /* if it's a directory */
- /* if it's a directory */
- if(S_ISDIR(buf.st_mode))
- {
- /* change to that directory, and update the FileSelectionBox */
- chdir(filename);
- XmFileSelectionDoSearch(w, NULL);
- }
- else
- /* if it's a regular file */
- if(S_ISREG(buf.st_mode))
- /* ask if it should be overwritten */
- XtManageChild(valbox);
- else
- /* it's another kind of file. What type, i can't think of,
- but it might happen */
- pop_up_error_box(client_data, "Error saving file");
- }
- else /* we couldn't get the file status */
- {
- /* if it's because the file doesn't exist, we're golden */
- if (errno == ENOENT)
- save_file();
- else /* there is some other problem getting the status.
- e.g. bad path */
- pop_up_error_box(client_data, "Error saving file");
- }
- }
-
- this still doesn't implement the file masking stuff.
-
-
- -----------------------------------------------------------------------------
- END OF PART TWO
- --
- +----------------------+---+
- Jan Newmarch, Information Science and Engineering,
- University of Canberra, PO Box 1, Belconnen, Act 2616
- Australia. Tel: (Aust) 6-2012422. Fax: (Aust) 6-2015041
- Xref: bloom-picayune.mit.edu comp.windows.x.motif:13659 news.answers:4510
- Newsgroups: comp.windows.x.motif,news.answers
- Path: bloom-picayune.mit.edu!enterpoop.mit.edu!news.media.mit.edu!micro-heart-of-gold.mit.edu!wupost!uunet!munnari.oz.au!manuel.anu.edu.au!csc.canberra.edu.au!news
- From: jan@ise.canberra.edu.au (Jan Newmarch)
- Subject: Motif FAQ (Part 3 of 5)
- Message-ID: <1992Dec10.001621.10506@csc.canberra.edu.au>
- Followup-To: comp.windows.x.motif
- Keywords: FAQ question answer
- Sender: news@csc.canberra.edu.au
- Reply-To: jan@ise.canberra.edu.au (Jan Newmarch)
- Organization: University of Canberra
- Date: Thu, 10 Dec 92 00:16:21 GMT
- Approved: news-answers-request@MIT.Edu
- Expires: +1 months
- Lines: 1147
-
- Archive-name: motif-faq/part3
- Last-modified: Thu December 12 1992
- Version: 2.12
-
-
-
- -----------------------------------------------------------------------------
- Subject: 57) TOPIC: FORM WIDGET
-
-
- -----------------------------------------------------------------------------
- Subject: 58) Why don't labels in a Form resize when the label is changed?
- I've got some labels in a form. The labels don't resize whenever the label
- string resource is changed. As a result, the operator has to resize the window
- to see the new label contents. I am using Motif 1.1.
-
- Answer: This problem may happen to any widget inside a Form widget. The
- problem was that the Form will resize itself when it gets geometry requests
- from its children. If its preferred size is not allowed, the Form will
- disallow all geometry requests from its children. The workaround is that you
- should set any ancestor of the Form to be resizable. For the shell which
- contains the Form you should set the shell resource XmNallowShellResize to be
- True (by default, it is set to FALSE). There is currently an inconsistency on
- how resizing is being done, and it may get fixed in Motif 1.2.
-
- From db@sunbim.be (Danny Backx)
-
- Basically what you have to do is set the XmNresizePolicy on the Form to
- XmRESIZE_NONE. The facts seem to be that XmRESIZE_NONE does NOT mean "do not
- allow resizes". You may also have to set XmNresizable on the form to True.
-
- -----------------------------------------------------------------------------
- Subject: 59) How can I center a widget in a form?
-
- Answer: One of Motif's trickier questions. The problems are that: Form gives
- no support for centering, only for edge attachments, and the widget must stay
- in the center if the form or the widget is resized. Just looking at
- horizontal centering (vertical is similar) some solutions are:
-
- a. Use the table widget instead of Form.
-
- b. A hack free solution is from Dan Heller:
-
- /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates.
- * This program is freely distributable without licensing fees and
- * is provided without guarantee or warranty expressed or implied.
- * This program is -not- in the public domain. This program is
- * taken from the Motif Programming Manual, O'Reilly Volume 6.
- */
-
- /* corners.c -- demonstrate widget layout management for a
- * BulletinBoard widget. There are four widgets each labeled
- * top-left, top-right, bottom-left and bottom-right. Their
- * positions in the bulletin board correspond to their names.
- * Only when the widget is resized does the geometry management
- * kick in and position the children in their correct locations.
- */
- #include <Xm/BulletinB.h>
- #include <Xm/PushBG.h>
-
- char *corners[] = {
- "Top-Left", "Top-Right", "Bottom-Left", "Bottom-Right",
- };
-
- static void resize();
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- Widget toplevel, bboard;
- XtAppContext app;
- XtActionsRec rec;
- int i;
-
- /* Initialize toolkit and create toplevel shell */
- toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
- &argc, argv, NULL, NULL);
-
- /* Create your standard BulletinBoard widget */
- bboard = XtVaCreateManagedWidget("bboard",
- xmBulletinBoardWidgetClass, toplevel, NULL);
-
- /* Set up a translation table that captures "Resize" events
- * (also called ConfigureNotify or Configure events). If the
- * event is generated, call the function resize().
- */
- rec.string = "resize";
- rec.proc = resize;
- XtAppAddActions(app, &rec, 1);
- XtOverrideTranslations(bboard,
- XtParseTranslationTable("<Configure>: resize()"));
-
- /* Create children of the dialog -- a PushButton in each corner. */
- for (i = 0; i < XtNumber(corners); i++)
- XtVaCreateManagedWidget(corners[i],
- xmPushButtonGadgetClass, bboard, NULL);
-
- XtRealizeWidget(toplevel);
- XtAppMainLoop(app);
- }
-
- /* resize(), the routine that is automatically called by Xt upon the
- * delivery of a Configure event. This happens whenever the widget
- * gets resized.
- */
- static void
- resize(w, event, args, num_args)
- CompositeWidget w; /* The widget (BulletinBoard) that got resized */
- XConfigureEvent *event; /* The event struct associated with the event */
- String args[]; /* unused */
- int *num_args; /* unused */
- {
- WidgetList children;
- int width = event->width;
- int height = event->height;
- Dimension w_width, w_height;
- short margin_w, margin_h;
-
- /* get handle to BulletinBoard's children and marginal spacing */
- XtVaGetValues(w,
- XmNchildren, &children,
- XmNmarginWidth, &margin_w,
- XmNmarginHeight, &margin_h,
- NULL);
-
- /* place the top left widget */
- XtVaSetValues(children[0],
- XmNx, margin_w,
-
- XmNy, margin_h,
- NULL);
-
- /* top right */
- XtVaGetValues(children[1], XmNwidth, &w_width, NULL);
-
- /* To Center a widget in the middle of the BulletinBoard (or Form),
- * simply call:
- * XtVaSetValues(widget,
- XmNx, (width - w_width)/2,
- XmNy, (height - w_height)/2,
- NULL);
- * and return.
- */
- XtVaSetValues(children[1],
- XmNx, width - margin_w - w_width,
- XmNy, margin_h,
- NULL);
- /* bottom left */
- XtVaGetValues(children[2], XmNheight, &w_height, NULL);
- XtVaSetValues(children[2],
-
- XmNx, margin_w,
- XmNy, height - margin_h - w_height,
- NULL);
- /* bottom right */
- XtVaGetValues(children[3],
- XmNheight, &w_height,
- XmNwidth, &w_width,
- NULL);
- XtVaSetValues(children[3],
- XmNx, width - margin_w - w_width,
- XmNy, height - margin_h - w_height,
- NULL);
- }
-
- c. No uil solution has been suggested, because of the widget size problem
-
- -----------------------------------------------------------------------------
- Subject: 60) How do I line up two columns of widgets of different types? I
- have a column of say label widgets, and a column of text widgets and I want to
- have them lined up horizontally. The problem is that they are of different
- heights. Just putting them in a form or rowcolumn doesn't line them up
- properly because the label and text widgets are of different height.
-
- If you want the geometry to look like this
-
- -------------------------------------
- | -------------------------- |
- |a label |Some text ||
- | -------------------------- |
- ------------------- |
- |a longer label |Some more text ||
- | ------------------- |
- | ---------------- |
- |a very long label |Even more text ||
- | ---------------- |
- -------------------------------------
-
- try
-
- /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates.
- * This program is freely distributable without licensing fees and
- * is provided without guarantee or warranty expressed or implied.
- * This program is -not- in the public domain. This program is
- * taken from the Motif Programming Manual, O'Reilly Volume 6.
- */
-
- /* text_form.c -- demonstrate how attachments work in Form widgets.
- * by creating a text-entry form type application.
- */
-
- #include <Xm/PushB.h>
- #include <Xm/PushBG.h>
- #include <Xm/LabelG.h>
- #include <Xm/Text.h>
- #include <Xm/Form.h>
-
- char *prompts[] = {
- "Name:", "Phone:", "Address:",
- "City:", "State:", "Zip:",
- };
-
- main(argc, argv)
- int argc;
- char *argv[];
- {
- Widget toplevel, mainform, subform, label, text;
- XtAppContext app;
- char buf[32];
- int i;
-
- toplevel = XtVaAppInitialize(&app, "Demos", NULL, 0,
- &argc, argv, NULL, NULL);
-
- mainform = XtVaCreateWidget("mainform",
- xmFormWidgetClass, toplevel,
- NULL);
-
- for (i = 0; i < XtNumber(prompts); i++) {
- subform = XtVaCreateWidget("subform",
- xmFormWidgetClass, mainform,
- /* first one should be attached for form */
- XmNtopAttachment, i? XmATTACH_WIDGET : XmATTACH_FORM,
- /* others are attached to the previous subform */
- XmNtopWidget, subform,
- XmNleftAttachment, XmATTACH_FORM,
- XmNrightAttachment, XmATTACH_FORM,
- NULL);
- label = XtVaCreateManagedWidget(prompts[i],
- xmLabelGadgetClass, subform,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNalignment, XmALIGNMENT_BEGINNING,
- NULL);
- sprintf(buf, "text_%d", i);
- text = XtVaCreateManagedWidget(buf,
- xmTextWidgetClass, subform,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- XmNrightAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_WIDGET,
- XmNleftWidget, label,
- NULL);
- XtManageChild(subform);
- }
- /* Now that all the forms are added, manage the main form */
- XtManageChild(mainform);
-
- XtRealizeWidget(toplevel);
- XtAppMainLoop(app);
- }
-
- If you resize horizontally it stretches the text widgets. If you resize
- vertically it leaves space under the bottom (if you don't resize, this is not
- problem).
-
- If you want the text widgets to be lined up on the left, as in
-
- ----------------------------------------
- | ------------------- |
- | a label |Some text ||
- | ------------------- |
- ------------------- |
- | a longer label |Some more text ||
- | ------------------- |
- | ------------------- |
- |a very long label |Even more text ||
- | ------------------- |
- ----------------------------------------
-
- try this
-
- /* Written by Dan Heller. Copyright 1991, O'Reilly && Associates.
- * This program is freely distributable without licensing fees and
- * is provided without guarantee or warranty expressed or implied.
- * This program is -not- in the public domain. This program is
- * taken from the Motif Programming Manual, O'Reilly Volume 6.
-